<%--
  Created by IntelliJ IDEA.
  User: 铃
  Date: 2024/9/29
  Time: 9:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div id="text" align="center" style="text-align: center">
    <h1>花卉信息列表</h1>
<%--    <input type="button" value="查询" id="select">--%>
    <br>
    <table align="center" width="60%" style="text-align: center" cellspacing="0" cellpadding="0" border="1" id="table1">
        <thead>
        <td width='10%'>花卉编号</td>
        <td width='20%'>花卉名称</td>
        <td width='15%'>别名</td>
        <td width='15%'>科属</td>
        <td width='15%'>价格（元/支）</td>
        <td width='25%'>原产地</td>

        </thead>
    </table>

    <table align="center" width="60%" style="text-align: center" cellspacing="0" cellpadding="0" border="1" id="table">

    </table>
    <a href="add.jsp" style="text-decoration: none;color:red;">增加花卉信息</a>
</div>
</body>
<script src="js/jquery.js"></script>
<script>
    window.onload=function (){
        $.ajax({
            "url":"/flowerServlet",
            "type":"post",
            "dataType":"json",
            "success":function (data){
                console.log(data)
                $("#table").empty();
                for (var i = 0; i < data.length; i++) {
                    var $tr="<tr id='neirong'><td width='10%'>"+data[i].id+"</td><td width='20%'>"+data[i].name+"</td><td width='15%'>"+data[i].anothername+"</td><td width='15%'>"+data[i].property+"</td><td width='15%'>"+data[i].price+"</td><td width='25%'>"+data[i].production+"</td></tr>"
                    $("#table").append($tr);
                }
            }
        })
    }
</script>
</html>
